﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ModuloAdministrativo
{
    public partial class InsumoAtualizarForm : Form
    {
        private int ID;

        public InsumoAtualizarForm()
        {
            InitializeComponent();
        }
        public InsumoAtualizarForm(string nome, string qtdAdd, string unidade, string id)
        {
            InitializeComponent();
            nomeTB.Text = nome;
            unidadeCB.SelectedItem = unidade;
            this.ID = int.Parse(id);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            double temp1 = 0;
            double temp2 = 0;
           
            if(!quantidadeAddTB.Text.Equals(""))
                temp1 = double.Parse(quantidadeAddTB.Text);
            if (!quantidadeRemTB.Text.Equals(""))
                temp2 = double.Parse(quantidadeRemTB.Text);
            
            double temp = temp1-temp2;
            
            WSsiar.InsumoBean insumobean = new WSsiar.InsumoBean();
            insumobean.ID = ID;
            insumobean.Nome = nomeTB.Text;
            insumobean.QuantidadeEstoque = temp;
            insumobean.Unidade = unidadeCB.SelectedItem.ToString();
            WSsiar.ServicosSIARSoapClient ws = new WSsiar.ServicosSIARSoapClient();
            ws.InsumoAtualizar(insumobean);
        }

        private void InsumoAtualizarForm_Load(object sender, EventArgs e)
        {
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            WSsiar.ServicosSIARSoapClient ws = new WSsiar.ServicosSIARSoapClient();
            ws.InsumoDeletar(ID);
        }
    }
}
